package entityclasses;

import strategies.ShareStrategy;
import factories.ShareStrategyFactory;
import java.io.*;
import java.util.*;
import strategies.ShareStrategy;
import factories.ShareStrategyFactory;
import entityclasses.Person;

public class Share {

    private ShareStrategy shareStrategy;
    private String content;
    public static final int PlainText = 0;
    public static final int LinkText = 1;

    public Share(String content) {
        
        int type;
        
        if (content.contains("http://")) {
            type = Share.LinkText;
        } else {
            type = Share.PlainText;
        }

        setContent(content);
        setShareStrategy(ShareStrategyFactory.createShareStrategy(type));
    }

    /**
     * @return the shareStrategy
     */
    public ShareStrategy getShareStrategy() {
        return shareStrategy;
    }

    /**
     * @param shareStrategy the shareStrategy to set
     */
    public final void setShareStrategy(ShareStrategy shareStrategy) {
        this.shareStrategy = shareStrategy;
    }

    /**
     * @return the content
     */
    public String getContent() {
        return content;
    }

    /**
     * @param content the content to set
     */
    public final void setContent(String content) {
        this.content = content;
    }

    public void shareItem(Person person) {
        person.getProfile().getShares().add(this);
        //return getShareStrategy().share(getContent());
    }
}
